package cn.cubix.flow.mybatisplus;

import cn.hutool.core.lang.generator.SnowflakeGenerator;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor(onConstructor=@__({@Autowired,@Lazy}))
public class CusIdentifierGenerator implements IdentifierGenerator {

    private final SnowflakeGenerator snowflakeGenerator;

    @Override
    public Number nextId(Object entity) {
        log.debug("CusIdGenerator.nextId->cn.hutool.core.lang.generator.SnowflakeGenerator");
        return snowflakeGenerator.next();
    }
}
